package psn.kiko.controller.iconfont;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import psn.kiko.annotation.api.StableID;
import psn.kiko.pojo.PageResult;
import psn.kiko.pojo.Result;
import psn.kiko.pojo.dto.IconFontDTO;
import psn.kiko.pojo.vo.IconFontVO;
import psn.kiko.service.business.system.IconFontService;

import java.util.List;

/**
 *字体图标接口
 */
@RestController
@RequestMapping("/admin/iconfont")
@Api(tags = {"字体图标管理"})
public class IconFontController{
	@Autowired
	IconFontService iconFontService;
	
	@PostMapping("/selectList/{pageNUm}/{pageSize}")
	@ApiOperation("携带条件地分页查询")
	@StableID(501)
	public Result selectList(
			@PathVariable("pageNUm") @ApiParam("页码") int pageNUm,
			@PathVariable("pageSize") @ApiParam("页面大小") int pageSize,
			@RequestBody @ApiParam("字体图标DTO") IconFontDTO iconFontDTO
	){
		PageResult pageResult=iconFontService.getIconFonts(iconFontDTO,pageNUm,pageSize);
		return Result.success(pageResult);
	}
	
	@GetMapping("/getIconFont/{id}")
	@ApiOperation("根据主键获取")
	@StableID(502)
	public Result select(
			@PathVariable("id") @ApiParam("主键") int id
	){
		IconFontVO iconFontVO =iconFontService.getIconFont(id);
		return Result.success(iconFontVO);
	}
	
	@PostMapping("/addIconFont")
	@ApiOperation("新增字体图标")
	@StableID(503)
	public Result add(
			@RequestBody @ApiParam("字体图标DTO") IconFontDTO iconFontDTO
	){
		Integer r=iconFontService.addIconFont(iconFontDTO);
		return Result.success(r);
	}
	
	@PutMapping("/editIconFont")
	@ApiOperation("编辑字体图标")
	@StableID(504)
	public Result edit(
			@RequestBody @ApiParam("字体图标DTO") IconFontDTO iconFontDTO
	){
		Integer r=iconFontService.editIconFont(iconFontDTO);
		return Result.success(r);
	}
	
	@DeleteMapping("/batchDeleteIconFonts")
	@ApiOperation("删除一批字体图标")
	@StableID(505)
	public Result add(
			@RequestBody @ApiParam("字体图标id集合") List<Integer> iconFontIds
	){
		Integer r=iconFontService.deleteIconFonts(iconFontIds);
		return Result.success(r);
	}
}
